package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.MirrorChartCategoryDao;
import com.xbongbong.admin.domain.entity.MirrorChartCategoryEntity;
import com.xbongbong.admin.model.MirrorChartCategoryModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @auther: xingxing.xiao
 * @date: 2020/3/6 006 15:46
 */
@Service("mirrorChartCategoryModel")
public class MirrorChartCategoryModelImpl implements MirrorChartCategoryModel {

    @Resource
    private MirrorChartCategoryDao mirrorChartCategoryDao;

    @Override
    public Integer insert(MirrorChartCategoryEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return mirrorChartCategoryDao.insert(entity);
    }

    @Override
    public Integer update(MirrorChartCategoryEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return mirrorChartCategoryDao.update(entity);
    }

    @Override
    public List<MirrorChartCategoryEntity> findEntitys(Map<String, Object> param) {
        return mirrorChartCategoryDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return mirrorChartCategoryDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer deleteByKey(Long key, Long mirrorId) {
        return mirrorChartCategoryDao.deleteByKey(key, mirrorId);
    }

    /**
     * 通过主键获取数据
     * @author xingxing.xiao
     */
    @Override
    public MirrorChartCategoryEntity getByKey(Long key, Long mirrorId) {
        return mirrorChartCategoryDao.getByKey(key, mirrorId);
    }

    /**
     * 批量插入数据
     * @param list 实体列表
     */
    @Override
    public List<MirrorChartCategoryEntity> insertBatch(List<MirrorChartCategoryEntity> list) {
        mirrorChartCategoryDao.insertBatch(list);
        return list;
    }

    @Override
    public MirrorChartCategoryEntity getByMirrorId(Long mirrorId, Long parent) {
        return mirrorChartCategoryDao.getByMirrorId(mirrorId,parent);
    }

}
